<?php
include_once 'sql_connect.php'; 
function uploadHead($h_data,$h_data_origin){
	$u_no = $_COOKIE['u_no'];

	$head_sql = mysql_query("select * from head where u_no='$u_no'",$connection);
	$head_result = mysql_fetch_array($head_sql);
	
	/*查看该用户是否已有头像*/
	/*若不曾上传头像*/
	if(!$head_result){
		msg("未上传");
		$my_sql = mysql_query("select MAX(h_id) from head",$connection); /*检查head表中得最大id编号*/
		$my_result = mysql_fetch_array($my_sql);

		/*对将要输入head表的数据项量进行赋值*/
		$h_id = $my_result[0] + 1;

		/*插入数据*/
		mysql_query("insert into head values('$h_id','$h_data','$h_data_origin','$u_no')",$connection);
	}
	/*已有头像*/
	else {
		/*更新数据*/
		mysql_query("UPDATE head SET h_data='$h_data',h_data_origin='$h_data_origin' WHERE u_no='$u_no'");
	}
}
?>